package schema

import (
	"entgo.io/ent"
	"entgo.io/ent/dialect/entsql"
	"entgo.io/ent/schema"
	"entgo.io/ent/schema/field"
	"entgo.io/ent/schema/index"
	"private-domain-overseas-service/pkg/status/bizintegral"
	"time"
)

// HzIntegralOrder holds the schema definition for the HzIntegralOrder entity.
type HzIntegralOrder struct {
	ent.Schema
}

// Fields HzIntegralOrder Fields of the HzIntegralOrder.
func (HzIntegralOrder) Fields() []ent.Field {
	return []ent.Field{
		field.Int64("order_user_id").Comment("用户ID"),
		field.Int64("order_goods_id").Default(0).Comment("兑换商品id"),
		field.Text("order_goods_info").MaxLen(5000).NotEmpty().Comment("订单商品信息(商品标题-商品描述)-多语言版本"),
		field.String("order_goods_small_image").Optional().Comment("订单商品列表图片"),
		field.String("order_goods_image").NotEmpty().Comment("订单商品主图片"),
		field.Int64("order_goods_number").Default(1).Comment("订单商品数量"),
		field.String("order_no").Immutable().NotEmpty().Comment("订单编号"),
		field.Int64("order_goods_amount").Immutable().Default(0).Comment("订单商品原价（百分之一）"),
		field.Int64("order_pay_amount").Default(0).Comment("订单支付积分（百分之一）"),
		field.Int64("order_status").Default(bizintegral.UnReceived).Comment("订单领取状态,1、待领取，2,已领取"),
		field.Text("order_original_goods_info").Immutable().NotEmpty().Comment("订单商品原始数据-快照"),
		field.String("order_goods_secret").Optional().Comment("订单商品卡密"),
		field.Int64("created_at").Immutable().Default(time.Now().Unix()).Comment("创建时间"),
		field.Int64("update_at").Default(time.Now().Unix()).Comment("更新时间"),
		field.Int64("delete_at").Optional().Comment("删除时间"),
	}
}

// Indexes of the Street.
func (HzIntegralOrder) Indexes() []ent.Index {
	return []ent.Index{
		index.Fields("order_user_id"),
		index.Fields("order_goods_id"),
		index.Fields("order_status"),
		index.Fields("order_no").Unique(),
	}
}

func (HzIntegralOrder) Annotations() []schema.Annotation {
	return []schema.Annotation{
		entsql.WithComments(true),
		schema.Comment("积分商城订单表"),
	}
}
